*ssc install outreg2
*ssc install xtoverid
*ssc install ivreg2
*ssc install xtivreg2
*ssc install outtable

clear all
set more off, permanently

* Set directory
cd "~MyDirectory/ReplicationFiles"

set matsize 10000
set more off, permanently



***********************************
** Convoys
***********************************

clear all
*use "Data/BELARUS_VILLAGES_dind.dta", clear
use "Data/BELARUS_VILLAGES_matched_v1.dta", clear
xtset VID POST


gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

xtreg H_ALL3 T_CONVOYS POST DIND_CONVOYS, fe

matrix X = J(1, 9, 0)

* Next 3 months
quietly xtreg P_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

* Rest of war
quietly xtreg P_ALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* During op + Next 3 months
quietly xtreg P_DALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_DALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_DALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

* During op + Rest of war
quietly xtreg P_DALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_DALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_DALL T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

matrix colnames X = PeopleKilled Lower_p Upper_p HousesDestroyed Lower_h Upper_h Reprisals Lower_r Upper_r 
matrix X = X[2...,1..9]
matrix rownames X = Next3Months NextYear DuringNext3Months DuringNextYear 
matrix list X

*outtable using "Output/RailWar_CONVOYS_DinD.tex", mat(X) nobox caption("Difference in differences, partisan interdiction.") replace
outtable using "Output/RailWar_CONVOYS_DinD_matched.tex", mat(X) nobox caption("Difference in differences, partisan interdiction. Matched sample.") replace


*******************





***********************************
** Coercion
***********************************

clear all
*use "Data/BELARUS_VILLAGES_dind.dta", clear
use "Data/BELARUS_VILLAGES_matched_v2.dta", clear
xtset VID POST


gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"


matrix X = J(1, 9, 0)

* Next 3 months
quietly xtreg P_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

* Rest of war
quietly xtreg P_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* During op + Next 3 months
quietly xtreg P_DALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_DALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_DALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

* During op + Rest of war
quietly xtreg P_DALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_DALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_DALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]

matrix colnames X = PeopleKilled Lower_p Upper_p HousesDestroyed Lower_h Upper_h Reprisals Lower_r Upper_r 
matrix X = X[2...,1..9]
matrix rownames X = Next3Months NextYear DuringNext3Months DuringNextYear 
matrix list X

*outtable using "Output/RailWar_COERCION_DinD.tex", mat(X) nobox caption("Difference in differences, partisan coercion.") replace
outtable using "Output/RailWar_COERCION_DinD_matched.tex", mat(X) nobox caption("Difference in differences, partisan coercion. Matched sample.") replace





**********************************************************************
**********************************************************************
**********************************************************************
** MOVING TIME WINDOW
**********************************************************************
**********************************************************************
**********************************************************************



***********************************
** Convoys
***********************************

clear all
*use "Data/BELARUS_VILLAGES_dind.dta", clear
use "Data/BELARUS_VILLAGES_matched_v1.dta", clear
xtset VID POST

matrix X = J(1, 9, 0)


* Next 1 month
use "Data/BELARUS_VILLAGES_matched_v1_tz1.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL1 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL1 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL1 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 2 months
use "Data/BELARUS_VILLAGES_matched_v1_tz2.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL2 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL2 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL2 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 3 months
use "Data/BELARUS_VILLAGES_matched_v1_tz3.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL3 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 4 months
use "Data/BELARUS_VILLAGES_matched_v1_tz4.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL4 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL4 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL4 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 5 months
use "Data/BELARUS_VILLAGES_matched_v1_tz5.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL5 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL5 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL5 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 6 months
use "Data/BELARUS_VILLAGES_matched_v1_tz6.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL6 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_CONVOYS"]'
matrix m1ll = m["ll","DIND_CONVOYS"]'
matrix m1ul = m["ul","DIND_CONVOYS"]'

quietly xtreg H_ALL6 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_CONVOYS"]'
matrix m2ll = m["ll","DIND_CONVOYS"]'
matrix m2ul = m["ul","DIND_CONVOYS"]'

quietly xtreg R_ALL6 T_CONVOYS POST DIND_CONVOYS, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_CONVOYS"]'
matrix m3ll = m["ll","DIND_CONVOYS"]'
matrix m3ul = m["ul","DIND_CONVOYS"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Rest of war
quietly xtreg P_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


matrix colnames X = PeopleKilled Lower_p Upper_p HousesDestroyed Lower_h Upper_h Reprisals Lower_r Upper_r 
matrix X = X[2...,1..9]
matrix rownames X = Next1Months Next2Months Next3Months Next4Months Next5Months Next6Months NextYear
matrix list X

*outtable using "Output/RailWar_CONVOYS_DinD.tex", mat(X) nobox caption("Difference in differences, partisan interdiction.") replace
outtable using "Output/RailWar_CONVOYS_DinD_matched_tz.tex", mat(X) nobox caption("Difference in differences, partisan interdiction. Matched sample.") replace
outtable using "Latex/Figures3_RR/RailWar_CONVOYS_DinD_matched_tz.tex", mat(X) nobox caption("Difference in differences, partisan interdiction. Matched sample.") f(%9.2f) replace



***********************************
** Coercion
***********************************

clear all
*use "Data/BELARUS_VILLAGES_dind.dta", clear
use "Data/BELARUS_VILLAGES_matched_v1.dta", clear
xtset VID POST

matrix X = J(1, 9, 0)


* Next 1 month
use "Data/BELARUS_VILLAGES_matched_v1_tz1.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL1 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL1 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL1 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 2 months
use "Data/BELARUS_VILLAGES_matched_v1_tz2.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL2 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL2 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL2 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 3 months
use "Data/BELARUS_VILLAGES_matched_v1_tz3.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL3 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 4 months
use "Data/BELARUS_VILLAGES_matched_v1_tz4.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL4 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL4 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL4 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 5 months
use "Data/BELARUS_VILLAGES_matched_v1_tz5.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL5 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL5 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL5 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Next 6 months
use "Data/BELARUS_VILLAGES_matched_v1_tz6.dta", clear
xtset VID POST
gen DIND_CONVOYS = T_CONVOYS*POST
label variable DIND_CONVOYS "Difference in differences (convoys)"
gen DIND_COERCION = T_COERCION*POST
label variable DIND_COERCION "Difference in differences (garrisons)"

quietly xtreg P_ALL6 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL6 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL6 T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


* Rest of war
quietly xtreg P_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m1b = m["b", "DIND_COERCION"]'
matrix m1ll = m["ll","DIND_COERCION"]'
matrix m1ul = m["ul","DIND_COERCION"]'

quietly xtreg H_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m2b = m["b", "DIND_COERCION"]'
matrix m2ll = m["ll","DIND_COERCION"]'
matrix m2ul = m["ul","DIND_COERCION"]'

quietly xtreg R_ALL T_COERCION POST DIND_COERCION, fe
matrix m = r(table)
matrix m3b = m["b", "DIND_COERCION"]'
matrix m3ll = m["ll","DIND_COERCION"]'
matrix m3ul = m["ul","DIND_COERCION"]'

matrix m0t = [ m1b , m1ll , m1ul, m2b , m2ll , m2ul, m3b , m3ll , m3ul  ]
matrix X= [X \ m0t]


matrix colnames X = PeopleKilled Lower_p Upper_p HousesDestroyed Lower_h Upper_h Reprisals Lower_r Upper_r 
matrix X = X[2...,1..9]
matrix rownames X = Next1Months Next2Months Next3Months Next4Months Next5Months Next6Months NextYear
matrix list X

outtable using "Output/RailWar_COERCION_DinD_matched_tz.tex", mat(X) nobox caption("Difference in differences, partisan interdiction. Matched sample.") replace

